from PyCmpltrtok.common import sep
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

text_generation_zh = pipeline(Tasks.text_generation, model='damo/nlp_gpt3_text-generation_chinese-base')  # nlp TextGenerationPipeline({'model': '/home/yppei/.cache/modelscope/hub/damo/nlp_gpt3_text-generation_chinese-large', 'device': 'gpu'}) https://modelscope.cn/docs/api_docs/API%E6%96%87%E6%A1%A3%2Fbuild%2Fjson%2Fapi%2Fgenerated%2Fmodelscope.pipelines.nlp.TextGenerationPipeline


def text_gen(xinput):
    xresult = text_generation_zh(xinput)
    return xresult


result_zh = text_generation_zh("随着计算机视觉的飞速发展,人脸识别技术已从简单场景发展到复杂场景,也即姿态、光照、表情、噪声、遮挡、化妆、年龄、种族、性别等差异化所呈现的复杂场景。尽管已有的人脸识别系统在特定约束环境下的识别成功率较高,")
result_text = result_zh['text']
print(result_text)

for i in range(3):
    sep(i)
    result_zh = text_generation_zh(result_text)
    result_text = result_zh['text']
    print(result_text)
